<?php $CI =& get_instance();?>
<script>
APP = $merge(APP, {
	base: '<?php echo site_url(array('users',$usrAlias,'bap'))?>',
	utils: '<?php echo site_url(array('utils'))?>'
});
</script>
<?php 
	//create status signed, if already signed
	$CI->load->model('bap_model');
	$CI->load->model('bap_sign_model');
	$hasSigned = $CI->bap_model->is_signed_by_witnesses($bapData['bap_id']);
?>
<h2 style="border-bottom: 1px solid #ccc;">
Laporan Perbuatan :: <?php echo $perbData['perb_id']?> [Report Approved] <?php if($hasSigned):?>[Signed by Witness Team]<?php endif?>
</h2>

<h3 style="padding-bottom: 5; margin-bottom: 0; display: inline;">
	<span id="perbuatanView_icon">-</span> 
	<a id="perbuatanView_button" style="cursor: pointer; color: black" onclick="APP.slide.perbuatanView.toggle()">Laporan Perbuatan</a>
</h3>
<div id="perbuatanView">
<h4 style="padding-bottom: 5; margin-bottom: 0; padding-left: 10px ">Pelapor</h4>
<table cellpadding="5" style="margin-left: 5px" cellspacing="0" width="100%">
<?php if ($laporData['lapor_nik']):?>
<tr>
	<td>NIK:</td>
	<td colspan="2"><?php echo $laporData['lapor_nik']?></td>
</tr>
<?php endif;?>
<tr>
	<td width="20%">Nama:</td>
	<td colspan="2"><?php echo $laporData['lapor_nama']?></td>
</tr>
<tbody id="noPelaporID" style="display: table-row-group; ">
<?php if ($laporData['lapor_nik']): ?>
<?php $CI->load->model('pelapor_alamat_model')?>
<?php $alamat = $CI->pelapor_alamat_model->select_by_pelapor($laporData['lapor_id'])?>
<?php foreach ($alamat->result_array() as $row):?>
<tr>
	<td>Alamat:</td>
	<td width="40%"><?php echo $row['lapor_alm_alamat']?></td>
	<td valign="top"><?php echo $row['lapor_alm_kota']?></td>
</tr>
<?php endforeach;?>
<?php $CI->load->model('pelapor_telepon_model')?>
<?php $tlp = $CI->pelapor_telepon_model->select_by_pelapor($laporData['lapor_id'])?>
<?php foreach($tlp->result_array() as $row):?>
<tr>
	<td>Telepon:</td>
	<td><?php echo $row['lapor_tlp_no']?>
	</td>
</tr>
<?php endforeach;?>
<?php endif;?>
</tbody>
</table>

<h4 style="padding-bottom: 5; margin-bottom: 0; padding-left: 10px ">Perbuatan</h4>
<table cellpadding="5" style="margin-left: 5px" cellspacing="0" width="100%">
<tr>
	<td width="20%">Tanggal Lapor:</td>
	<td><?php echo $perbData['perb_tgl_lapor']?></td>
</tr>
<tr>
	<td>Tanggal Kejadian:</td>
	<td><?php echo $perbData['perb_tgl_kejadian']?></td>
</tr>
<tr>
	<td>Tempat Kejadian:</td>
	<td><?php echo $perbData['perb_tempat_kejadian']?></td>
</tr>
<tr>
	<td valign="top"><div style="padding-top: 2px">Kategori Perbuatan:</div></td>
	<td><?php echo $deperbData[0]['detachiev_nama']?>
	</td>
</tr>
<tr>
	<td width="50px">Jenis:</td>
	<td><?php echo $jenis_options[$deperbData[0]['achiev_jenis']]?></td>
</tr>
<tr>
	<td>Bidang:</td>
	<td><?php echo $deperbData[0]['achiev_bidang']?></td>
</tr>
<tr>
	<td>Tingkat:</td>
	<td><?php echo $tingkat_options[$deperbData[0]['detachiev_tingkat']]?></td>
</tr>
<tr>
	<td>Karyawan Pelaku:</td>
	<td>
		<?php $TMP = (array)$CI->karyawan_model->select_by_id($deperbData[0]['kary_id'])->row()?>
		<?php echo $TMP['kary_nama']?>
		<?php foreach ($CI->karyawan_history_jabatan_model->select_by_id($deperbData[0]['kary_jbt_id'])->result_array() as $row):?>
			<?php if ($row['kary_jbt_id']==$deperbData[0]['kary_jbt_id']) echo $row['jbt_nama']." [".$row['dep_nama']."]"?>
		<?php endforeach;?>
	</td>
</tr>
<?php
$ind=1;
foreach($deperbData as $pelaku):
if ($pelaku['kary_id'] == $deperbData[0]['kary_id']) continue; //skip the first index 
?>
<tr>
	<td></td>
	<td>
		<?php $TMP = (array)$this->karyawan_model->select_by_id($pelaku['kary_id'])->row()?>
		<?php echo $TMP['kary_nama']?>
		<?php foreach ($CI->karyawan_history_jabatan_model->getActive($pelaku['kary_id'])->result_array() as $row):?>
			<?php if ($pelaku['kary_jbt_id']==$row['kary_jbt_id']) echo $row['jbt_nama']." [".$row['dep_nama']."]"?>
		<?php endforeach;?>
	</td>
</tr>
<?php endforeach?>
<tr>
	<td valign="top"><div style="padding-top: 2px" >Keterangan:</div></td>
	<td><?php echo trim($perbData['perb_keterangan'])?></td>
</tr>
<tr>
	<td valign="top"><div style="padding-top: 2px">Bukti:</div></td>
	<td>
		<div class="fcUpload"> 
		<ul class="fcUpload-list">
			<?php foreach($buktiperbData as $bukti):?>
			<li class="file " id="file-1" style="background-color: transparent; ">
				<a class="file-title fakeLink" onclick="showImage(
					'<?php echo $bukti['perb_dok_file_name'] ?>',
					'<?php echo $bukti['perb_dok_file_name']?>',
					APP.base+'/ajax/loadImage/<?php echo $bukti['perb_dok_id']?>')">
					<?php echo $bukti['perb_dok_file_name']?>
				</a>
				<span class="file-size"><?php echo number_format($bukti['perb_dok_file_size']/1024,2)." kB"?></span>
			</li>
			<?php endforeach?>
		</ul> 
	</div> 
 	</td>
</tr>
</table>
</div>

<h3 style="padding-bottom: 5; margin-bottom: 0; padding-top: 20px">
	<span id="notificationView_icon">-</span> 
	<a id="notificationView_button" style="cursor: pointer; color: black" onclick="APP.slide.notificationView.toggle()">Approve Notification</a>
</h3>
<div id="notificationView">
<input type="hidden" name="inp[RE][0]" value="<?php echo $perbData['perb_id']?>" />

<?php $CI->load->model('bap_model')?>
<?php $bapData = (array)$CI->bap_model->select_by_perbID($perbData['perb_id'])->row()?>
<table cellpadding="5" width="100%">
<tr>
	<td width="20%">Tgl pembuatan :</td>
	<td><?php echo $bapData['bap_tgl']?></td>
</tr>
<tr>
	<?php $CI->load->model('karyawan_model')?>
	<?php $karyData = (array)$CI->karyawan_model->select_by_id($bapData['bap_pembuat_kary_id'])->row()?>
	<td>Oleh :</td>
	<td><?php echo $karyData['kary_nama']?></td>
</tr>
<tr>
	<?php $CI->load->model('jabatan_model')?>
	<?php $jbtData = (array)$CI->karyawan_history_jabatan_model->select_by_id($bapData['bap_pembuat_kary_jbt_id'])->row()?>
	<td>Jabatan :</td>
	<td><?php echo $jbtData['jbt_nama']?> [<?php echo $jbtData['dep_nama']?>]</td>
</tr>
<tr>
	<td colspan="2">
		<div style="border: 1px solid #CCC; padding: 10px"><?php echo $bapData['bap_pembuat_keterangan']?></div>
	</td>
</tr>
</table>
</div>

<div id="counterOuterView">
	<h3 style="padding-bottom: 5; margin-bottom: 0; padding-top: 20px">
		<span id="counterView_icon">-</span> 
		<a id="counterView_button" style="cursor: pointer; color: black">Counter Notification</a>
	</h3>
	<form action="<?php echo site_url(array('users',$usrAlias,'bap','ajax','counter','save'))?>" method="post">
		<input type="hidden" name="inp[CO][perb_id]" value="<?php echo $perbData['perb_id']?>" />
		<input type="hidden" name="inp[CO][bap_id]" value="<?php echo $bapData['bap_id']?>" />
		<input type="hidden" name="inp[CO][pembuat][kary_id]" value="<?php echo $bapData['kary_id']?>" />
		<input type="hidden" name="inp[CO][pembuat][kary_jbt_id]" value="<?php echo $bapData['kary_jbt_id']?>" />
		<div id="fcUpload">
			<table cellpadding="5" width="100%">
			<tr>
				<td width="20%" valign="top"><div style="padding-top: 2px">Bukti:</div></td>
				<td>
					<input id="fcUpload-check" type="hidden" class="validate['required','target:fcUpload-attach']" />
					<a href="#" id="fcUpload-attach">Attach a file</a> 
					<ul id="fcUpload-list"></ul> 
					<a href="#" id="fcUpload-attach-2" style="display: none;">Attach another file</a>
				</td>
			</tr>
			<tr><td></td><td></td></tr>
			</table> 
		</div>
		<div id="msg[CO]" style="width: 600px"></div>
		<textarea name="inp[CO][keterangan]" class="RTE validate['required','target:msg[CO]']"></textarea>
	</form>
</div>

<div id="btGroup1" style="border-top:1px solid #ccc; text-align: center; padding-top: 10px; margin-top: 20px">
	<form action="<?php echo site_url(array('users',$usrAlias,'bap','ajax','signing','AC'))?>" method="post">
	<input type="hidden" name="bap_id" value="<?php echo $bapData['bap_id']?>" />
	<input type="button" value="I'm disagree, I would like to create counter notification" class="buttonRed" onclick="APP.slide.counterOuterView.toggle()" />
	<input type="submit" value="I'm agree and signing this notification" class="buttonRed" onclick="$(this).getParent('form').submit()" />
	<input type="button" value="Cancel" class="button" onclick="document.location=APP.base" />
	</form>
</div>

<div id="btGroup2" style="border-top:1px solid #ccc; text-align: center; padding-top: 10px; margin-top: 20px; display: none;">
	<input type="button" value="Save & Send" class="buttonRed" onclick="$('counterOuterView').getElement('form').fireEvent('submit'); this.disabled=true" />
	<input type="button" value="Cancel" class="button" onclick="APP.slide.counterOuterView.toggle()" />
</div>